function ajax(option) {
    return new Promise((resolve, reject) => {
        let xhr = new XMLHttpRequest();
        xhr.open(option.method, option.url, option.async);
        if (option.method === 'POST') {
            xhr.send(option.data);
        } else {
            xhr.send();
        }
        
        //readystatechange > loadstart > readystatechange > readystatechange > progress > readystatechange > load / error > loadend 
        //readystatechange 每次触发时 readyState 值不同。
        xhr.onreadystatechange = function (e) {
            console.log('onreadystatechange ',e)
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    resolve(this.responseText);
                } else {
                    reject();
                }
            }
        }
    });
}